﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.WebPages.Html;

namespace Cinematograph.Extentions
{
    public static class DateList
    {
        public static  IEnumerable<System.Web.Mvc.SelectListItem> GetDays(int selected = 0)
        {
            List<System.Web.Mvc.SelectListItem> days = new List<System.Web.Mvc.SelectListItem>(31);
            for (int i = 0; i <= 31; i++)
            {
                if (i == selected)
                    days.Add(new System.Web.Mvc.SelectListItem { Text = i.ToString(), Selected = true });
                else
                    days.Add(new System.Web.Mvc.SelectListItem { Text = i.ToString() });
                    
            }
            return days.AsEnumerable<System.Web.Mvc.SelectListItem>();
        }

        public static IEnumerable<System.Web.Mvc.SelectListItem> GetMonths(int selected = 0)
        {
            List<System.Web.Mvc.SelectListItem> months = new List<System.Web.Mvc.SelectListItem>();
            for (int i = 0; i <= 12; i++)
            {
                if (i == selected)
                    months.Add(new System.Web.Mvc.SelectListItem { Text = i.ToString(), Selected = true });
                else
                    months.Add(new System.Web.Mvc.SelectListItem { Text = i.ToString() });
            }
            return months.AsEnumerable<System.Web.Mvc.SelectListItem>();
        }

        public static IEnumerable<System.Web.Mvc.SelectListItem> GetYears(int selected = 0)
        {
            List<System.Web.Mvc.SelectListItem> years = new List<System.Web.Mvc.SelectListItem>();
            for (int i = 1900; i <= 2012; i++)
            {
                if (i == selected)
                    years.Add(new System.Web.Mvc.SelectListItem { Text = i.ToString(), Selected = true });
                else
                    years.Add(new System.Web.Mvc.SelectListItem { Text = i.ToString() });
            }
            return years.AsEnumerable<System.Web.Mvc.SelectListItem>();
        }
    }
}